//
//  MYViewController.m
//  StartFortuneNew
//
//  Created by 邹渊峰 on 14-10-17.
//  Copyright (c) 2014年 niit. All rights reserved.
//

#import "MYViewController.h"
#import "ShareController.h"
#import "SmallImage.h"
#import "AppDelegate.h"
@interface MYViewController ()<UIScrollViewDelegate>


@end

@implementation MYViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.bl=[NetBL sharedNetBL];
    
    [self.bl getDataBL];

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getDatasuccess:) name:kNotificationGetDataBLSuccessBL object:nil];
    AppDelegate *delegate=(AppDelegate*)[[UIApplication sharedApplication]delegate];
    NSLog(@"%ld",(long)delegate.imageID);
    
    self.title=@"星座运势";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"分享" style:UIBarButtonItemStyleBordered target:self action:@selector(share)];
    
    //添加主题图片
    [self.headImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%ld.gif",(long)delegate.imageID+1]]];

    self.scrollView.bounces=NO;
    self.scrollView.contentSize=CGSizeMake(320, self.view.frame.size.height);
}

-(void)getDatasuccess:(NSNotification *)n
{
    self.arr=n.object;
    self.allFortune.text= [NSString stringWithFormat:@"%@",[self.arr[0] objectForKey:@"rank"]];
    self.loveFortune.text=[NSString stringWithFormat:@"%@",[self.arr[1] objectForKey:@"rank"]];
    self.workFortune.text=[NSString stringWithFormat:@"%@",[self.arr[2] objectForKey:@"rank"]];
    self.moneyFortune.text=[NSString stringWithFormat:@"%@",[self.arr[3] objectForKey:@"rank"]];
    self.healthFortune.text=[self.arr[4] objectForKey:@"value"];
    self.businessFortune.text=[self.arr[5] objectForKey:@"value"];
    self.luckyColor.text=[self.arr[6] objectForKey:@"value"];
    self.luckyNumber.text=[self.arr[7] objectForKey:@"value"];
    self.fitStar.text=[self.arr[8] objectForKey:@"value"];
    self.allDescribe.text=[self.arr[9] objectForKey:@"value"];
    self.timeInfo.text=[NSString stringWithString:self.arr[11]];
    
    [[NSNotificationCenter defaultCenter]removeObserver:self name:kNotificationGetDataBLSuccessBL object:nil];
}

- (void)share
{
    ShareController *sharecorl = [[ShareController alloc]init];
    [self.navigationController pushViewController:sharecorl animated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
